package com.supermap.originTest;


import com.supermap.data.Workspace;
import com.supermap.data.WorkspaceConnectionInfo;
import com.supermap.data.WorkspaceType;
import com.supermap.data.processing.MapCacheBuilder;
import com.supermap.data.processing.StorageType;
import com.supermap.mapping.Map;
import com.supermap.tilestorage.TileStorageConnection;


public class TestWuwenkang {

	/**
	 * 程序入口点
	 * The entrance of the programme.
	 */
	public static void main(String[] args) {

//

//
//
//		

		try {
			MapCacheBuilder mapCacheBuilder = new MapCacheBuilder();

			Workspace workspace = new Workspace();
			WorkspaceConnectionInfo conInfo = new WorkspaceConnectionInfo(
					"E:\\MapData\\202404\\test\\WorkSpace.smwu");

			conInfo.setType(WorkspaceType.SMWU);
			workspace.open(conInfo);

			Map map = new Map(workspace);
			map.fromXML(workspace.getMaps().getMapXML(0));

			mapCacheBuilder.setMap(map);
			mapCacheBuilder.setStorageType(StorageType.MongoDB);

			TileStorageConnection tileStorageConnection = new TileStorageConnection();
			tileStorageConnection.setDatabase("test");
			tileStorageConnection.setServer("127.0.0.1");
			mapCacheBuilder.setConnectionInfo(tileStorageConnection);

			mapCacheBuilder.setCacheName("myTest23");
			mapCacheBuilder.setClipRegion(map.getClipRegion());
			mapCacheBuilder.setOutputScales(new double[]{0.005});
			mapCacheBuilder.setOutputFolder("E:\\MapData\\202407");
			mapCacheBuilder.build();
		} catch (Exception e) {
			throw new RuntimeException(e);
		}


//		Resources resources = workspace.getResources();
//		SymbolLibrary symbolLibrary = resources.getFillLibrary();
//		SymbolGroup desGroup = symbolLibrary.getRootGroup();
//
//		SymbolFill fill = new SymbolFill();
//		String fileName = "Ellipsoid";
//		fill.setName(fileName);
//		SymbolFillLibrary fillLibrary = (SymbolFillLibrary) desGroup.getLibrary();
//		if (null != fillLibrary) {
//			SymbolMarkerLibrary inlineMarkerLibrary = fillLibrary.getInlineMarkerLib();
//			SymbolMarker marker = new SymbolMarker();
//			String imageUrl = "D:\\Ellipsoid.png";
//
//			marker.setName(fileName);
//			marker.fromPicturePath(imageUrl);
//
//
//			//将目标符号添加到填充符号库的内部点符号库中
//			int markerId = inlineMarkerLibrary.add(marker);
//			int fillSize = 350;
//			SymbolFillMarker symbolFillMarker = new SymbolFillMarker();
//			symbolFillMarker.setMarkerID(markerId);
//			symbolFillMarker.setWidth(fillSize);
//			symbolFillMarker.setHeight(fillSize);
//			symbolFillMarker.setMarkerSize(350);
//			ArrayList<Point> points = new ArrayList<>();
//			points.add(new Point(0, 0));
////			points.add(new Point(5, 70));
////			points.add(new Point(70, 70));
////			points.add(new Point(70, 5));
//			symbolFillMarker.setMarkerPoints(points);
//			SymbolFillBase symbolFillBase = new SymbolFillBase();
//			symbolFillBase.setFillMarker(symbolFillMarker);
//			symbolFillBase.setBaseType(SymbolFillBaseType.MarkerSymbol);
//			fill.add(symbolFillBase);
//			int id = fillLibrary.add(fill);
//			fillLibrary.moveTo(id, desGroup);
//			System.out.println(id);
//			workspace.save();
//
//			


//		}


	}

}

